package com.zbkj.crmeb.supplier.controller;

// import org.apache.shiro.authz.annotation.RequiresPermissions;

import javax.servlet.http.HttpServletRequest;

import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.CommonPage;
import com.common.PageParamRequest;
import com.crmeb.core.common.CommonResult;
import com.crmeb.core.exception.CrmebException;
import com.github.pagehelper.PageInfo;
import com.zbkj.crmeb.chant.dto.ApplyAuditAndSupplierDTO;
import com.zbkj.crmeb.merchant.admin.controller.AdminBaseController;
import com.zbkj.crmeb.merchant.api.controller.ApiBaseController;
import com.zbkj.crmeb.store.request.BusinessApplyRequest;
import com.zbkj.crmeb.store.response.BusinessApplyResponse;
import com.zbkj.crmeb.supplier.model.BusinessApply;
import com.zbkj.crmeb.supplier.service.BusinessApplyService;
import com.zbkj.crmeb.user.model.User;
import com.zbkj.crmeb.user.service.UserService;


/**
 * 某业务的注册申请表
 *
 * @author lss
 * @email didiok@foxmail.com
 * @date 2024-11-18 17:36:49
 */
@Slf4j
@RestController
@RequestMapping("api/admin/supplier/business/apply")
public class AdminBusinessApplyController extends AdminBaseController {
    @Autowired
    private BusinessApplyService businessApplyService;

    @Autowired
    private UserService userService;

    /**
     * 分页显示注册申请
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     */
    @ApiOperation(value = "注册申请分页列表")
    @RequestMapping(value = "/apply/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<BusinessApplyResponse>> getList(@Validated BusinessApplyRequest request, @Validated PageParamRequest pageParamRequest, HttpServletRequest servletRequest) {
        PageInfo<BusinessApplyResponse> pageInfo = new PageInfo<>();
        try {
            request.setMerId(getMerId(servletRequest));
            if(request.getMerId() == null || request.getMerId() == 0){
                throw new CrmebException("获取商户id异常!");
            }
            pageInfo = businessApplyService.getList(request, pageParamRequest);
        }catch (Exception e){
            log.error("注册申请分页列表查询报错，", e);
            throw new CrmebException("注册申请分页列表查询报错");
        }
        return CommonResult.success(CommonPage.restPage(pageInfo));
    }


}
